package com.huibo.shopping.product.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;

import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2
public class BaseConfig {
	@Bean
	public Docket getDocket() {
		return new Docket(DocumentationType.SWAGGER_2)
				.apiInfo(getApi())
				.select()
				.apis(RequestHandlerSelectors.basePackage("com.huibo.shopping.product.controller"))
				.paths(PathSelectors.any())
				.build();
	}
	
	public ApiInfo getApi() {
		return  new ApiInfoBuilder()
				.title("商品服务API")
				.description("商品服务接口文档说明")
				.contact(new Contact("keke","","1019510181@qq.com"))
				.version("1.0")
				.build();
	}
	
	/**
	 * @describe mybatis-plus自带的分页功能
	 * @return
	 */
	@Bean
	public PaginationInterceptor getPagintionIntercepter() {
		PaginationInterceptor pi = new PaginationInterceptor();
		return pi;
	}
}
